<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('PK对战列表')" />
</head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="pk-form">
				<div class="select-list">
					<ul>
						<li>
							<label>对战编号：</label>
							<input type="text" name="battleNo"/>
						</li>
						<li>
							<label>发起者ID：</label>
							<input type="text" name="initiatorId"/>
						</li>
						<li>
							<label>应战者ID：</label>
							<input type="text" name="challengerId"/>
						</li>
						<li>
							<label>对战状态：</label>
							<select name="battleStatus">
								<option value="">所有</option>
								<option value="1">等待应战</option>
								<option value="2">对战中</option>
								<option value="3">已结束</option>
							</select>
						</li>
						<li>
							<label>我的对战：</label>
							<select name="myBattle">
								<option value="">所有</option>
								<option value="initiator">我发起的</option>
								<option value="challenger">我参与的</option>
							</select>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:exam:pk:add">
				<i class="fa fa-plus"></i> 新增对战
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table"></table>
		</div>
	</div>
</div>

<th:block th:include="include :: footer" />

<script th:inline="javascript">
	var editFlag = [[${@permission.hasPermi('system:exam:pk:edit')}]];
	var prefix = ctx + "system/exam/pk";

	$(function() {
		var options = {
			url: prefix + "/list",
			queryParams: function(params) {
				var formData = $('#pk-form').serializeObject();
				return $.extend(true, params, formData);
			},
			createUrl: prefix + "/add",
			updateUrl: prefix + "/edit/{id}",
			removeUrl: prefix + "/remove",
			exportUrl: prefix + "/export",
			viewUrl: prefix + "/view/{id}",
			modalName: "PK对战",
			columns: [{
				checkbox: true
			},
			{
				field: 'id',
				title: '对战ID'
			},
			{
				field: 'battleNo',
				title: '对战编号',
				align: 'center'
			},
			{
				field: 'initiatorId',
				title: '发起者ID',
				align: 'center'
			},
			{
				field: 'challengerId',
				title: '应战者ID',
				align: 'center'
			},
			{
				field: 'configId',
				title: '配置ID',
				align: 'center'
			},
			{
				field: 'battleStatus',
				title: '对战状态',
				align: 'center',
				formatter: function(value, row, index) {
					if (value == 1) {
						return '<span class="label label-warning">等待应战</span>';
					} else if (value == 2) {
						return '<span class="label label-primary">对战中</span>';
					} else if (value == 3) {
						return '<span class="label label-success">已结束</span>';
					} else {
						return value;
					}
				}
			},
			{
				field: 'winnerId',
				title: '获胜者ID',
				align: 'center'
			},
			{
				field: 'startTime',
				title: '开始时间',
				align: 'center'
			},
			{
				field: 'endTime',
				title: '结束时间',
				align: 'center'
			},
			{
				field: 'createTime',
				title: '创建时间',
				align: 'center'
			},
			{
				title: '操作',
				align: 'center',
				formatter: function(value, row, index) {
					var actions = [];
					actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.view(\'' + row.id + '\')"><i class="fa fa-eye"></i> 查看</a> ');
					actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i> 编辑</a> ');
					actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-trash"></i> 删除</a>');
					return actions.join('');
				}
			}]
		};
		$.table.init(options);
	});
</script>
</body>
</html>